package com.roadmap.entities;

import java.util.Date;

import com.roadmap.common.BaseConst;
import com.roadmap.common.BaseAuthEntity;
import com.roadmap.common.RdcResourceBundle;

public class LifeTask extends BaseAuthEntity {
	private String goalId;
	private String aspirantId;
	private String content;
	private Date scheduledStartDate;
	private Date scheduledEndDate;
	private int executeCycle;
	private int taskRank;
	private int proportionOfGoal;
	private int status;
	private Date realStartDate;
	private Date realEndDate;
	private int selfScore;

	public LifeTask() {
		super();
		this.status = BaseConst.LIFETASK_STATUS_SCHEDULED;
		this.selfScore = 70;
		this.executeCycle = 1;
		this.taskRank = BaseConst.LIFETASK_RANK_ImportantAndUrgent;
		this.scheduledStartDate = this.getCreatedTime();
		this.scheduledEndDate = this.getCreatedTime();
		// in case, the task doesn't belong to a plan
		this.proportionOfGoal = 100;
	}

	public String getGoalId() {
		return goalId;
	}

	public void setGoalId(String goalId) {
		this.goalId = goalId;
	}

	public String getAspirantId() {
		return aspirantId;
	}

	public void setAspirantId(String aspirantId) {
		this.aspirantId = aspirantId;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public Date getScheduledStartDate() {
		return scheduledStartDate;
	}

	public void setScheduledStartDate(Date scheduledStartDate) {
		this.scheduledStartDate = scheduledStartDate;
	}

	public Date getScheduledEndDate() {
		return scheduledEndDate;
	}

	public void setScheduledEndDate(Date scheduledEndDate) {
		this.scheduledEndDate = scheduledEndDate;
	}

	public int getExecuteCycle() {
		return executeCycle;
	}

	public void setExecuteCycle(int executeCycle) {
		this.executeCycle = executeCycle;
	}

	public int getTaskRank() {
		return taskRank;
	}

	public void setTaskRank(int taskRank) {
		if (status > 0 && status < RdcResourceBundle.LIFETASK_RNAK_DESCRIPTIONS.length) {
			this.taskRank = taskRank;
		}
	}

	public int getProportionOfGoal() {
		return proportionOfGoal;
	}

	public void setProportionOfGoal(int proportionOfPlan) {
		this.proportionOfGoal = proportionOfPlan;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		if (status > 0 && status < RdcResourceBundle.LIFETASK_STATUS_DESCRIPTIONS.length) {
			this.status = status;
		}
	}

	public Date getRealStartDate() {
		return realStartDate;
	}

	public void setRealStartDate(Date realStartDate) {
		this.realStartDate = realStartDate;
	}

	public Date getRealEndDate() {
		return realEndDate;
	}

	public void setRealEndDate(Date realEndDate) {
		this.realEndDate = realEndDate;
	}

	public int getSelfScore() {
		return selfScore;
	}

	public void setSelfScore(int selfScore) {
		this.selfScore = selfScore;
	}

	@Override
	public String getWhatItIs() {
		if (getContent() != null && getContent().length() > DESP_MAX_LENGTH) {
			return getContent().substring(0, DESP_MAX_LENGTH) + "...";
		}
		return getContent();
	}

}
